<!--
 * @Description: iframe.html
 * @Author: rendc
 * @Date: 2025-11-14 09:50:07
 * @LastEditors: rendc
 * @LastEditTime: 2025-11-14 10:17:27
-->
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>iframe - iframeGetMessage - 父页面</title>
</head>

<body>
  <!-- iframe.html -->
  <!-- <iframe src="https://you.163.com/" width="3000" height="2000"></iframe> -->
  <!-- 通过iframe标签通信 -->
  <iframe id="iframeOne" src="http://127.0.0.1:5500/day22/iframeGetMessage.html" width="1000" height="500"></iframe>
  <!-- 导入 iframe -->
  <script src="./js/jquery.js"></script>
</body>
<script>
  // 获取iframe标签
  // var iframeOne = document.getElementById("iframeOne");
  // 使用jQuery获取元素
  var iframeOne = $("#iframeOne");
  console.log('🤡 CC - iframeOne:', iframeOne);
  // 确保iframeOne页面加载完成
  // iframeOne.addEventListener('load',function(){})
  iframeOne[0].addEventListener('load',()=>{
    console.log('🤡 CC - load:',);
    // 获取 iframeOne 的 window 对象
    var iframeOneWindow = iframeOne[0].contentWindow;
    console.log('🤡 CC - iframeOneWindow:', iframeOneWindow);
    // 发送消息 
    iframeOneWindow.postMessage("hello,this is parent");
  })
  
</script>
</html>